package com.lixixi.tingshu.user.api;

import com.lixixi.tingshu.common.anno.NeedLogin;
import com.lixixi.tingshu.common.result.Result;
import com.lixixi.tingshu.user.service.UserListenProcessService;
import com.lixixi.tingshu.vo.user.UserListenProcessVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Map;

@RestController
@RequestMapping("/api/user/userListenProcess")
public class UserListenProcessApiController {
	@Autowired
	UserListenProcessService userListenProcessService;

	// /getTrackBreakSecond/36612
	@GetMapping("/getTrackBreakSecond/{trackId}")
	@NeedLogin(isLogin = false)
	Result<BigDecimal> getTrackBreakSecond(@PathVariable("trackId") Long trackId){
		BigDecimal trackBreakSecond = userListenProcessService.getTrackBreakSecond(trackId);
		return Result.ok(trackBreakSecond);
	}

	//http://127.0.0.1/api/user/userListenProcess/updateListenProcess
	@PostMapping("/updateListenProcess")
	@NeedLogin(isLogin = false)
	Result updateListenProcess(@RequestBody UserListenProcessVo userListenProcessVo){
		userListenProcessService.updateListenProcess(userListenProcessVo);
		return Result.ok();
	}

	// http://127.0.0.1/api/user/userListenProcess/getLatelyTrack
	@GetMapping("/getLatelyTrack")
	@NeedLogin
	Result<Map<String, Object>> getLatelyTrack(){
		return Result.ok(userListenProcessService.getLatelyTrack());
	}

}
